<template>
  <el-dialog :visible.sync="isOpen" title="自定义链接" :append-to-body="true" width="500px" style="height: 400px" class="custom-url" @close="handleClose">
    <el-form ref="customUrlForm"  :model="custom"
             :rules="checkRules" label-width="100px">
      <el-form-item label="链接地址：" prop="url">
        <el-input v-model="custom.url" clearable/>
      </el-form-item>
    </el-form>
    <div slot="footer" class="dialog-footer">
<!--      <el-button @click="handleClose">取消</el-button>-->
      <el-button type="primary" @click="save">添加</el-button>
    </div>
  </el-dialog>
</template>

<script>
import {mapGetters} from 'vuex';
import {getCusPage} from '@/api/custom';
import {getSiteId} from '@/utils/auth';

export default {
    name: 'custom_url_dialog',
    props: {
        productDialogVisible: {
            type: Boolean,
            default: false
        }
    },
    watch: {
        productDialogVisible (newVal) {
            this.isOpen = newVal;
        }
    },
    data () {
        return {
            isOpen: this.productDialogVisible,
            custom: {
                url: ''
            },
            checkRules: {
                url: [
                    {required: true, message: '请输入url', trigger: 'blur'}

                ]
            }
        };
    },
    computed: {
        siteId () {
            return this.$store.state.user.siteId;
        }
    },
    created () {
    },
    methods: {
        save () {
            this.$refs.customUrlForm.validate(valid => {
                if (valid) {
                    this.$emit('save', this.custom);
                    this.isOpen = false;
                }
            });
        },
        handleClose () {
            this.isOpen = false;
            this.$emit('close');
        }
    }
};
</script>

<style scoped lang="scss">
.pagination {
  margin-top: 12px;
  text-align: right;
}
</style>

<style lang="scss">
.custom-url{
  .el-dialog__body{
    height: auto;
  }
}
</style>
